/***************************************************************
Creates Table 3 in-text (Experiments 1-4 merged analyses)
Also creates Tables OB9 and OB10 
OB9 is the full version of Table 2
OB10 includes control variables
****************************************************************/

clear
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Data"
use experiments1to4_merged.dta
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Table3"
log using "table3_log.log"

***********************Merged Analyses
encode experiment, gen(exp)
label var exp "Experiment"
label var support01 "Policy Support"

**Analyses
eststo clear
eststo: regress support01 i.treat i.exp
	*test
	test _b[2.treat] = _b[3.treat]
	*lincom
	lincom _b[2.treat] - _b[3.treat]

eststo: regress support01 i.treat i.exp i.stereo
	*test
	test _b[2.treat] = _b[3.treat]
	*lincom
	lincom _b[2.treat] - _b[3.treat]

eststo: regress support01 i.treat##i.stereo i.exp
	margins, dydx(treat) by(stereo) 
	margins, dydx(treat) by(stereo) post coeflegend
	*Stereotypical
	test _b[2.treat:2.stereo] =  _b[3.treat:2.stereo]
	lincom _b[2.treat:2.stereo] - _b[3.treat:2.stereo]
	
	*Counter-stereotypical
	 test _b[2.treat:1bn.stereo] =   _b[3.treat:1bn.stereo]
	 lincom _b[2.treat:1bn.stereo] -   _b[3.treat:1bn.stereo]

**Full Table (Appendix)**
esttab using tableob9.rtf, replace onecell label b(2) se star(+ 0.1 * 0.05 ** 0.01) ///
	title("{\b Table OB9}: Table 3 Results (Experiments 1-4 Merged)") ///
	nobaselevels

**Truncated Table (In-Text)**

esttab using table3.rtf, replace onecell label b(2) se star(+ 0.1 * 0.05 ** 0.01) ///
	title("{\b Table 3}: Experiments 1-4 Merged") ///
	nobaselevels keep(2.treat 3.treat 2.stereo 2.treat#2.stereo 3.treat#2.stereo) ///
	addnote("See Table OB9 for experiment fixed effects and Table OB10 for analyses that further control for pre-treatment demographics.")
	
	
/*******************************
Controls
*******************************/

label var pid_ext "PID Extremity"
label def pi 2 "Leaning Partisan" 3 "Not Strong Partisan" 4 "Strong Partisan"
label values pid_ext pi 

label var ideology "Symbolic Ideology"

label var age "Age"

label var gender "Gender"
label def gend 1 "Female" 0 "Male"
label values gender gend

label var race_eth "Race/Ethnicity"
label def rac 1 "White" 2 "Black" 3 "Hispanic" 4 "Asian" 5 "Other Race"
label values race_eth rac

label var educ "Education" 
label def ed 1 "HS or Less" 2 "Some College" 3 "BA Degree" 4 "Post-BA Degree"
label values educ ed

label var income "Income"


**Analyses
eststo clear
eststo: regress support01 i.treat i.exp ideology i.pid_ext age i.gender i.race_eth i.educ 
	*test
	test _b[2.treat] = _b[3.treat]
	*lincom
	lincom _b[2.treat] - _b[3.treat]

eststo: regress support01 i.treat i.exp i.stereo ideology i.pid_ext age i.gender i.race_eth i.educ 
	*test
	test _b[2.treat] = _b[3.treat]
	*lincom
	lincom _b[2.treat] - _b[3.treat]

eststo: regress support01 i.treat##i.stereo i.exp ideology i.pid_ext age i.gender i.race_eth i.educ 
	margins, dydx(treat) by(stereo) 
	margins, dydx(treat) by(stereo) post coeflegend
	*Stereotypical
	test _b[2.treat:2.stereo] =  _b[3.treat:2.stereo]
	lincom _b[2.treat:2.stereo] - _b[3.treat:2.stereo]
	
	*Counter-stereotypical
	 test _b[2.treat:1bn.stereo] =   _b[3.treat:1bn.stereo]
	 lincom _b[2.treat:1bn.stereo] -   _b[3.treat:1bn.stereo]

**Full Table (Appendix)**
*Note: Table OB10 has lincom results in it; these were added manually based on the foregoing command results
esttab using tableob10.rtf, replace onecell label b(2) se star(+ 0.1 * 0.05 ** 0.01) ///
	title("{\b Table OB10}: Table 3 Results w/Demographics (Experiments 1-4 Merged)") ///
	nobaselevels

	
	
log close
